import logging

import requests


class BaseApi:

    def request(self, data: dict):
        if "url" in data:
            return self.http_request(data)
        if 'rpc' == data.get("protocol"):
            return self.rpc_request(data)

    def http_request(self, data):
        """
        data格式：{'protocol': None, 'url': None, 'method': None, 'json': None, 'param': {}}
        :param data:
        :return:
        """
        resp = requests.request(**data)
        return resp

    def rpc_request(self, data):
        pass

    def tcp_request(self):
        pass
